import http from '@/service/http'
import config from '../config'

const baseUrl = config.DATACENTER_PERMISSION

export const _updateUserRole = (roleInfo) => {
  return http.$POST(`${baseUrl}/job/updateUserRole`, roleInfo)
}
/* 获取角色列表 */
export const _getRoleList = () => {
  return http.$GET(`${baseUrl}/job/list`)
}
/* 新增角色 */
export const _addRole = (data) => {
  return http.$POST(`${baseUrl}/job/add`, data)
}
/* 修改角色 */
export const _editRole = (data) => {
  return http.$POST(`${baseUrl}/job/edit`, data)
}
/* 冻结角色 */
export const _freezeRole = (data) => {
  return http.$POST(`${baseUrl}/job/freeze/` + data)
}
/* 解冻角色 */
export const _thawRole = (data) => {
  return http.$POST(`${baseUrl}/job/thaw/` + data)
}
/* 获取角色名单 */
export const _getUserByRole = (data) => {
  return http.$POST(`${baseUrl}/job/getUsersByJob`, data)
}
/* 解冻用户 */
export const _thawUser = (roleId, userId) => {
  return http.$POST(`${baseUrl}/job/thawUser/` + roleId + '/' + userId)
}
/* 冻结用户 */
export const _freezeUser = (roleId, userId) => {
  return http.$POST(`${baseUrl}/job/freezeUser/` + roleId + '/' + userId)
}
/* 查询未授权app集合 */
export const _getAllApp = () => {
  return http.$GET(`${baseUrl}/job/getAllApps`)
}
/* 授权app */
export const _grantApp = (data) => {
  return http.$POST(`${baseUrl}/job/grantApp`, data)
}
/* 删除用户角色 */
export const _deleteRole = (roleId, userId) => {
  return http.$POST(`${baseUrl}/job/deleteUserRole/` + roleId + '/' + userId)
}

// 删除岗位
export const _deleteJob = (jobId) => http.DELETE(`${baseUrl}/job/${jobId}`)